// pages/index/open-setting.js
import {getUserLocation} from '../../utils/getLocation'
import {getUserInfo} from '../../utils/getUserInfo'

Page({
  data: {
    canIUse: wx.canIUse('button.open-type.openSetting'),
    nextPage: '/pages/index/index'
  },
  onload (opts) {
    let _this = this
    this.setData({
      nextPage: opts.nextPage || _this.data.nextPage
    })
  },
  bindOpenSetting (res) {
    console.log(res)
    if (res.detail.authSetting['scope.userLocation']) {
      getUserLocation()
    } else {
      // wx.showModal({
      //   title: '提示',
      //   content: '发帖需要打开位置权限~'
      // })
    }
    if (res.detail.authSetting['scope.userInfo']) {
      getUserInfo()
    } else {
      // wx.showModal({
      //   title: '提示',
      //   content: '发帖需要您打开用户信息权限~'
      // })
    }
    wx.navigateBack()
  }
})
